<!-- 会员中心主内容区 -->
<header class="bg-red">
    <div class="a-bar">
        <a href="javascript:history.back()" class="a-back">
            <i class="arr left"></i>
            返回
        </a>
        <div class="a-name">
            草稿箱
        </div>
    </div>
</header>

<div class="page-article">
  <!-- 站内信：草稿箱 -->
  <div id="member_messagebox" class="member-messagebox">
    <div class="member-tabs">
      <a href="<{link app=b2c ctl=wap_member act=inbox}>"><em><{t}>收件箱<{/t}><{if $inbox_num!=0}>(<span class="item-unread"><{$inbox_num}></span>)<{/if}></em></a>
      <a href="<{link app=b2c ctl=wap_member act=track}>"><em><{t}>发件箱<{/t}></em></a>
      <a href="<{link app=b2c ctl=wap_member act=outbox}>" class="active"  style="color: #f48451"><em><{t}>草稿箱<{/t}><{if $outbox_num!=0}>(<span class="item-unread"><{$outbox_num}></span>)<{/if}></em></a>
      <a href="<{link app=b2c ctl=wap_member act=message}>"><em><{t}>问题反馈<{/t}></em></a>
    </div>
    <div class="member-mod member-messagebox-list">
      <table class="member-grid">
        <!-- 标题 -->
        <caption><span class="messagebox-action"><a 
        
        class="btn btn-simple action-batch-delete" rel="_request"><span><span><{t}>删除<{/t}></span></span></a></span><span class="messagebox-tip">共<i><{$total_msg}></i>条消息</span></caption>
        <thead>
          <tr>
            <th class="check"><input type="checkbox" name="" id="" class="x-check action-check-all"></th>
            <th><{t}>收件人<{/t}></th>
            <th><{t}>标题<{/t}></th>
            <th><{t}>时间<{/t}></th>
          </tr>
        </thead>
        <tbody class="first" id="list">
        <{if count($message)>0}>
        <{foreach item=msg from=$message name=name}>
          <tr class="handle<{if $smarty.foreach.name.iteration==1}> first<{/if}>">
            <td class="check"><input type="checkbox" name="delete[]"  value="<{$msg.comment_id}>" id="" class="x-check op-check-all" vtype="requiredcustom" data-validatormsg="请先选择消息后再删除"></td>
            <td class="adressee"><{if $msg.to_type == 1}><{t}>管理员<{/t}><{else}><{$msg.to_uname}><{/if}></td>
            <td class="title"><{$msg.title|nl2br}></td>
            <td class="time"><{$msg.time|cdate:SDATE_STIME}></td>
          </tr>
        <{/foreach}>
        <{else}>
          <tr class="first"><td colspan="4" class="no-information"><{t}>暂无消息<{/t}></td></tr>
        <{/if}>
        </tbody>
      </table>
    </div>
    <{pagers data=$pager}>
  </div>
</div>

<{if count($message)>0}>
<script>

$(".action-check-all").click(function(){   
        $(".op-check-all").prop("checked", this.checked);  
});

$(".handle").click(function(e){   
       if(e.target.tagName == 'INPUT') return;
        var id = this.getElement('input[type=checkbox]').value;
        location.href = Router.sendmsg.substitute({id:id}); 
});


$(".action-batch-delete").click(function(e){ 

var ischecked=false;
var deletedata;
$('.op-check-all').each(function(){
    // alert($(this).attr('checked'));
            if($(this).attr('checked')){
                ischecked=true;
            }
        });


if(ischecked===false)
    popup('请先选择消息后再删除'); 
else
{
    if(confirm('确定要删除消息吗？'))
    {
        
            $('.op-check-all').each(function(){
            if($(this).attr('checked')){
                $.post('<{link app=b2c ctl=wap_member act=deleteMsg}>','delete='+$(this).attr('value'),function(re){
                     });
                
            }
        });
           
    }
// window.location.href='<{link app=b2c ctl=wap_member act=outbox }>';
　setTimeout("window.location.href='<{link app=b2c ctl=wap_member act=outbox }>'",300);
}
    

});

function popup(msg) {
    var tpl = $('<div class="popup">' + msg + '</div>').appendTo(document.body);
    var timer = setTimeout(function(){
        tpl.remove();
    }, 3000);
}


</script>
<{/if}>
